#include "myudpserver.h"
#include <QUdpSocket>
#include <QDebug>

myUDPserver::myUDPserver()
{
  udpSocket = new QUdpSocket(this);
  qDebug()<<"1"<<endl;
  udpSocket->bind(8000,QUdpSocket::ShareAddress);
  qDebug()<<"2"<<endl;
  connect(udpSocket,&QUdpSocket::readyRead,this,&myUDPserver::dealData);
  qDebug()<<"3"<<endl;
}
void myUDPserver::dealData()
{
    qDebug()<<"4"<<endl;
    char buf[1024]={0};
    QHostAddress cliAddr;
    quint16 port;
    qint64 len=udpSocket->readDatagram(buf,sizeof(buf),&cliAddr,&port);
    qDebug()<<"5"<<endl;
    if(len>0)
    {

        QString qtstr=QString(QLatin1String(buf));
        qDebug()<<qtstr<<endl;
    }
}
